<template>
  <div class="quitApproval">
    <div class="contLeft">
      <h2>申请离职</h2>
      <div class="topTit">
        <img src="@/assets/common/img.jpeg" alt>
        <div class="info">
          <p class="name">
            <strong>{{ information.username }} </strong>
          </p>
          <p>
            <span>部门：{{ information.departmentName }}</span>
          </p>
          <p>
            <span>入职时间： {{ information.timeOfEntry | formatDate }}</span>
          </p>
        </div>
      </div>
      <div class="content">
        <p>
          <span>申请类型：</span>离职
        </p>
        <p>
          <span>期望离职时间：</span>
          {{ information.data.end_time | formatDate }}
        </p>
        <p>
          <span>离职原因：</span>
          {{ information.data.reason }}
        </p>
      </div>
    </div>
    <div class="contRit">
      <div class="topTit">
        <strong>审批记录</strong>
      </div>
      <div class="Items">
        <li v-for="(item, index) in taskInstanceOutList" :key="index">
          <div class="name" :style="index==taskInstanceOutList.length-1?'border-right:none':''">
            <p>{{ item.handleTime | formatDate }}</p>
            <!-- <p>{{item.description}}</p> -->
          </div>
          <div class="act">
            <strong>{{ item.handleUserName }} </strong>
            <span v-if="index==0">发起申请</span>
            <span v-else-if="item.handleType == '3'">审批驳回</span>
            <span v-else-if="item.handleType == '4'">已撤销</span>
            <span v-else-if="item.handleType == '1'">未开始</span>
            <span v-else-if="item.handleType == '2'">审批通过</span>
            <span v-else>审批中</span>
          </div>
        </li>
      </div>
    </div>
  </div>
</template>

<script>
import { getApprovalsTaskDetail, getApprovalsDetail } from '@/api/approvals'
export default {
  data() {
    return {
      // url传过来的id
      id: this.$route.params.id,
      information: {
        data: {}
      },
      taskInstanceOutList: []
    }
  },
  created() {
    this.getApprovalsDetail()
    this.getApprovalsTaskDetail()
    console.log(this.id)
  },
  methods: {
    async getApprovalsDetail() {
      this.information = await getApprovalsDetail(this.id)
      this.information.data = JSON.parse(this.information.procData)
      console.log(this.information)
      console.log(this.information.data)
    },
    async getApprovalsTaskDetail() {
      this.taskInstanceOutList = await getApprovalsTaskDetail(this.id)
      console.log(this.taskInstanceOutList)
    }
  }
}
</script>

<style>

</style>

